<script lang="ts" setup>
// const { data } = await useFetch('/api/pageview')
const { data, pending, refresh, error } = await useAsyncData(() => $fetch('/api/test/pageview', {
  method: 'POST',
  body: {
    test: '123',
  },
}))
</script>

<template>
  <div class="app-container">
    <div v-if="pending">
      loading...
    </div>
    <div v-else-if="data">
      <div>{{ data.pageview }}</div>
      <div>{{ data.startAt }}</div>
      <div>{{ data.test }}</div>
    </div>
    <button @click="refresh()">
      refresh
    </button>
    <div v-if="error">
      {{ error }}
    </div>
  </div>
</template>
